<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>/data/HEFR/1/tech_num/iTimer_Projekt/src/modeSwitcher.vhdl.html</title>
<meta name="Generator" content="Vim/7.2">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000"><font face="monospace">
<font color="#00008b">---------------------------------------------------------------------------</font><br>
<br>
<font color="#00008b">-- Company&nbsp;&nbsp;&nbsp;&nbsp; : EIA / HTA </font><br>
<font color="#00008b">-- Author&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: Yves Peissard &lt;ypeissard@gmail.com&gt;</font><br>
<font color="#00008b">-- </font><br>
<font color="#00008b">-- Creation Date : 18/04/2009</font><br>
<font color="#00008b">-- File&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: modeSwitcher.vhdl</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">-- Abstract : This is the modeSwitcher of the iTimer project</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;it defines the out going busMode</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in function of the inputs</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inputs: </font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;alarm&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;: std_logic, 1 if the alarm is on</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0 if the alarm is off</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;simplePush : std_logic, 1 if the main button</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;was pressed for a short time</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;longPush&nbsp;&nbsp; : std_logic, 1 if the main button</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;was pressed for a long time</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clockInput :&nbsp;&nbsp;std_logic, clock signal</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Output:</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;busMode&nbsp;&nbsp;&nbsp;&nbsp;:&nbsp;&nbsp;std_logic_vector, &quot;00&quot; : Edit mode</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;01&quot; : Timer mode</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;10&quot; : Pause mode</font><br>
<font color="#00008b">--&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;11&quot; : Alarm mode</font><br>
<font color="#00008b">--</font><br>
<font color="#00008b">---------------------------------------------------------------------------</font><br>
<br>
<font color="#a52a2a"><b>library</b></font>&nbsp;ieee<font color="#6a5acd">;</font><br>
<font color="#a52a2a"><b>use</b></font>&nbsp;ieee<font color="#6a5acd">.</font>std_logic_1164<font color="#6a5acd">.</font><font color="#a52a2a"><b>ALL</b></font><font color="#6a5acd">;</font><br>
<font color="#a52a2a"><b>use</b></font>&nbsp;ieee<font color="#6a5acd">.</font>numeric_std<font color="#6a5acd">.</font><font color="#a52a2a"><b>all</b></font><font color="#6a5acd">;</font><br>
<br>
<font color="#00008b">---------------------------------------------------------------------------</font><br>
<font color="#a52a2a"><b>entity</b></font>&nbsp;modeSwitcher <font color="#a52a2a"><b>is</b></font>&nbsp;<br>
<font color="#00008b">---------------------------------------------------------------------------</font><br>
<font color="#a52a2a"><b>port</b></font>&nbsp;<font color="#6a5acd">(</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;busMode&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>out</b></font>&nbsp;<font color="#2e8b57"><b>std_logic_vector</b></font><font color="#6a5acd">(</font><font color="#ff00ff">1</font>&nbsp;<font color="#a52a2a"><b>downto</b></font>&nbsp;<font color="#ff00ff">0</font><font color="#6a5acd">);</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;alarm<font color="#6a5acd">,</font>simplePush<font color="#6a5acd">,</font>longPush<font color="#6a5acd">,</font>clockInput <font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>in</b></font>&nbsp;&nbsp;<font color="#2e8b57"><b>std_logic</b></font><br>
<font color="#6a5acd">);</font><br>
<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>entity</b></font>&nbsp;modeSwitcher<font color="#6a5acd">;</font><br>
<br>
<br>
<font color="#00008b">---------------------------------------------------------------------------</font><br>
<font color="#a52a2a"><b>architecture</b></font>&nbsp;modeSwitcher_arch <font color="#a52a2a"><b>of</b></font>&nbsp;modeSwitcher <font color="#a52a2a"><b>is</b></font><br>
<font color="#00008b">---------------------------------------------------------------------------</font><br>
<br>
<font color="#00008b">-- type declaration</font><br>
<font color="#a52a2a"><b>type</b></font>&nbsp;state <font color="#a52a2a"><b>is</b></font>&nbsp;<font color="#6a5acd">(</font>state_edit<font color="#6a5acd">,</font>&nbsp;state_timer<font color="#6a5acd">,</font>&nbsp;state_pause<font color="#6a5acd">,</font>&nbsp;state_alarm<font color="#6a5acd">);</font>&nbsp;<br>
<br>
<font color="#00008b">-- internal signals</font><br>
<font color="#a52a2a"><b>signal</b></font>&nbsp;state_future<font color="#2e8b57"><b>:</b></font>&nbsp;state<font color="#6a5acd">;</font><br>
<font color="#a52a2a"><b>signal</b></font>&nbsp;state_present<font color="#2e8b57"><b>:</b></font>&nbsp;state<font color="#6a5acd">;</font><br>
<font color="#a52a2a"><b>signal</b></font>&nbsp;old_simplePush<font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#2e8b57"><b>std_logic</b></font>&nbsp;<font color="#2e8b57"><b>:=</b></font>&nbsp;<font color="#ff00ff">'0'</font>&nbsp;<font color="#6a5acd">;</font><br>
<font color="#a52a2a"><b>signal</b></font>&nbsp;old_longPush<font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#2e8b57"><b>std_logic</b></font>&nbsp;<font color="#2e8b57"><b>:=</b></font>&nbsp;<font color="#ff00ff">'0'</font>&nbsp;<font color="#6a5acd">;</font><br>
<font color="#a52a2a"><b>signal</b></font>&nbsp;old_alarm<font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#2e8b57"><b>std_logic</b></font>&nbsp;<font color="#2e8b57"><b>:=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">;</font><br>
<br>
<font color="#a52a2a"><b>begin</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- chooses the future state</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- old_alarm, old_simplePush and old_longPush are used here to save</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- the states of alarm, simplePush and longPush of the</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- precedent clock cycle</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;state_chooser<font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>process</b></font>&nbsp;<font color="#6a5acd">(</font>state_present<font color="#6a5acd">,</font>&nbsp;simplePush<font color="#6a5acd">,</font>&nbsp;longPush<font color="#6a5acd">,</font>&nbsp;alarm<font color="#6a5acd">)</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>begin</b></font><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>case</b></font>&nbsp;state_present <font color="#a52a2a"><b>is</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- choose the behavior if we are in edit mode</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>when</b></font>&nbsp;state_edit <font color="#2e8b57"><b>=&gt;</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;<font color="#6a5acd">((</font>old_simplePush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;simplePush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">)</font>&nbsp;<font color="#2e8b57"><b>or</b></font>&nbsp;<font color="#6a5acd">(</font>old_longPush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;longPush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">))</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state_future <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;state_timer<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- choose the behavior if we are in timer mode</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>when</b></font>&nbsp;state_timer <font color="#2e8b57"><b>=&gt;</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;<font color="#6a5acd">((</font>old_simplePush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;simplePush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">)</font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;<font color="#6a5acd">(</font>alarm <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">))</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state_future <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;state_pause<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>elsif</b></font>&nbsp;<font color="#6a5acd">((</font>old_longPush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;longPush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">)</font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;alarm <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font><font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state_future <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;state_edit<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>elsif</b></font>&nbsp;<font color="#6a5acd">(</font>old_alarm <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;alarm <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state_future <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;state_alarm<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- choose the behavior if we are in pause mode</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>when</b></font>&nbsp;state_pause <font color="#2e8b57"><b>=&gt;</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;<font color="#6a5acd">(</font>old_simplePush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;simplePush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state_future <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;state_timer<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>elsif</b></font>&nbsp;<font color="#6a5acd">(</font>old_longPush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;longPush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">)</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state_future <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;state_edit<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- choose the behavior if we are in alarm mode</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>when</b></font>&nbsp;state_alarm <font color="#2e8b57"><b>=&gt;</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;<font color="#6a5acd">((</font>old_simplePush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;simplePush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">)</font>&nbsp;<font color="#2e8b57"><b>or</b></font>&nbsp;<font color="#6a5acd">(</font>old_longPush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'0'</font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;longPush <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font><font color="#6a5acd">))</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state_future <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;state_edit<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>case</b></font><font color="#6a5acd">;</font><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- update the old_* variables</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;old_simplePush <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;simplePush<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;old_longPush <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;longPush<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;old_alarm <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;alarm<font color="#6a5acd">;</font><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>process</b></font>&nbsp;state_chooser<font color="#6a5acd">;</font><br>
<br>
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">--- Register process ---</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;register_proc<font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>process</b></font><font color="#6a5acd">(</font>clockInput<font color="#6a5acd">)</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>begin</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>if</b></font>&nbsp;clockInput<font color="#2e8b57"><b>'event</b></font>&nbsp;<font color="#2e8b57"><b>and</b></font>&nbsp;clockInput <font color="#2e8b57"><b>=</b></font>&nbsp;<font color="#ff00ff">'1'</font>&nbsp;<font color="#a52a2a"><b>then</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;state_present <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;state_future<font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>if</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>process</b></font>&nbsp;register_proc<font color="#6a5acd">;</font><br>
<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">--- Output circuit process ---</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#00008b">-- define busMode</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;out_circuit<font color="#2e8b57"><b>:</b></font>&nbsp;<font color="#a52a2a"><b>process</b></font><font color="#6a5acd">(</font>state_present<font color="#6a5acd">)</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>begin</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>case</b></font>&nbsp;state_present <font color="#a52a2a"><b>is</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>when</b></font>&nbsp;state_edit <font color="#2e8b57"><b>=&gt;</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;busMode <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">&quot;00&quot;</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>when</b></font>&nbsp;state_timer <font color="#2e8b57"><b>=&gt;</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;busMode <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">&quot;01&quot;</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>when</b></font>&nbsp;state_pause <font color="#2e8b57"><b>=&gt;</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;busMode <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">&quot;10&quot;</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>when</b></font>&nbsp;state_alarm <font color="#2e8b57"><b>=&gt;</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;busMode <font color="#2e8b57"><b>&lt;=</b></font>&nbsp;<font color="#ff00ff">&quot;11&quot;</font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>when</b></font>&nbsp;<font color="#a52a2a"><b>others</b></font>&nbsp;<font color="#2e8b57"><b>=&gt;</b></font><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>case</b></font><font color="#6a5acd">;</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>process</b></font>&nbsp;out_circuit<font color="#6a5acd">;</font><br>
<font color="#a52a2a"><b>end</b></font>&nbsp;<font color="#a52a2a"><b>architecture</b></font>&nbsp;modeSwitcher_arch<font color="#6a5acd">;</font><br>
</font></body>
</html>
